import Alert from "../alert/Alert";
import TipMgr from "../tip/TipMgr";
import PanelMgr from "../view/PanelMgr";
import UIBase from "../view/UIBase";
import UIMgr from "../view/UIMgr";
import Wait from "../wait/Wait";
import EGPanelGreen from "./EGPanelGreen";
import EGPanelYellow from "./EGPanelYellow";
import EGUIBag from "./EGUIBag";


export default class EGUIMain extends UIBase {
    protected onInit(): void {
        this.skinPath = 'mi/example/EGUIMain';
    }

    protected onButtonClick(button: cc.Button): void {
        switch (button.node.name) {
            case 'BtnPanelYellow':
                PanelMgr.show(EGPanelYellow);
                break;
            case 'BtnPanelGreen':
                PanelMgr.show(EGPanelGreen);
                break;
            case 'BtnTip':
                TipMgr.inst.addTip('哈哈哈哈哈哈哈哈哈哈');
                break;
            case 'BtnAlert':
                Alert.inst.show('你好啊', () => {
                    TipMgr.inst.addTip('点击了确定按钮');
                    Alert.inst.show('只会显示确定按钮', () => { TipMgr.inst.addTip('点击了确定按钮'); });
                }, () => { TipMgr.inst.addTip('点击了取消按钮'); });
                break;
            case 'BtnWait':
                Wait.inst.show(true);
                const timer = setInterval(() => {
                    clearInterval(timer);
                    Wait.inst.show(false);
                }, 3000);
                break;
            case 'BtnUIBag':
                UIMgr.open(EGUIBag);
                break;
        }
    }
}
